<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var merge = function(nums1, m, nums2, n) {
    nums1.splice(m,n)
    nums1.splice(m,0,...nums2)
    nums1.sort( (a,b) => a-b )
    return nums1
};

var nums1 = [1,2,3,0,0,0]
m = 3
var nums2 = [2,5,6]
n = 3
console.log(merge(nums1, m, nums2, n))
    </script>
</body>
</html>